﻿// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "AsynchronousLoading.generated.h"

/**	异步加载
 *		为了避免阻塞主线程，可以使用异步加载的方式来加载资源
 *		异步加载完成后，可以设置回调函数
 *		创建 FStreamableManager，建议将它放在某类全局游戏单件对象中，如使用GameSingletonClassName 在 DefaultEngine.ini 中指定的对象
 */
UCLASS()
class MISCELLANEOUSPROJECT_API UAsynchronousLoading : public UObject
{
	GENERATED_BODY()
public:
	// 异步加载非蓝图类资源 FSoftObjectPath(单文件加载)
	void SingleRequestAsyncLoadMethod();
	// 异步加载非蓝图类资源 FSoftObjectPath(多文件加载)
	void MultiRequestAsyncLoadMethodOne();
	void MultiRequestAsyncLoadMethodTwo();

	// 异步加载蓝图类	单文件加载 FSoftClassPath 、TSoftClassPtr
	void SingleBPClassLoadMethod();
	
private:
	UPROPERTY(EditAnywhere, Category = "SoftObjectPath", meta = (AllowedClasses = "StaticMesh"))
	FSoftObjectPath SingeleObject;
	UFUNCTION()
	void OnSingleAssetLoadFinshed();

	UPROPERTY(EditAnywhere, Category="SoftObjectPath", meta = (AllowedClasses = "StaticMesh"))
	TArray<FSoftObjectPath> ObjectList1;
	UFUNCTION()
	void OnMultiAssetsLoadFinshedOne();
	UPROPERTY(EditAnywhere, Category = "SoftObjectPath")
	TArray<TSoftObjectPtr<UTexture2D>> ObjectList2;
	UFUNCTION()
	void OnMultiAssetsLoadFinshedTwo();

	UPROPERTY(EditAnywhere, Category = "SoftClassPath", meta = (MetaClass = "Actor"))
	FSoftClassPath SingleClassPath;
	UFUNCTION()
	void OnSingleClassLoadFinshed();
};


